
// 通过对时间的判断，返回指定格式
function formatTimeFun(t) {
    function e(t) {
        return t = "" + t,
        t.length < 2 && (t = "0" + t),
            t
    }

    var a = new Date;
    t = new Date(Date.parse(t.replace(/-/g, "/")));
    var n = {
        year: a.getFullYear(),
        month: a.getMonth(),
        date: a.getDate()
    }
        , i = {
        year: t.getFullYear(),
        month: t.getMonth(),
        date: t.getDate(),
        day: t.getDay(),
        hours: t.getHours(),
        minutes: t.getMinutes()
    }
        , o = ["日", "一", "二", "三", "四", "五", "六"];
    return n.year === i.year && n.month === i.month && n.date === i.date ? e(i.hours) + ":" + e(i.minutes) : n.year === i.year && n.month === i.month && n.date === i.date + 1 ? "昨天 " + e(i.hours) + ":" + e(i.minutes) : function (t, e) {
                var a = parseInt(t.getTime() / 864e5)
                    , n = parseInt(e.getTime() / 864e5);
                return parseInt((a - 3) / 7) === parseInt((n - 3) / 7)
            }(a, t) ? "星期" + o[i.day] + " " + e(i.hours) + ":" + e(i.minutes) : n.year === i.year ? e(i.month + 1) + "-" + e(i.date) + " " + e(i.hours) + ":" + e(i.minutes) : i.year + "-" + e(i.month + 1) + "-" + e(i.date) + " " + e(i.hours) + ":" + e(i.minutes)
}

module.exports = {
	formatTime : formatTimeFun
}